package com.wei.storage.controller;

import com.wei.common.entity.Storage;
import com.wei.common.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @author weichuanyuan
 * @version 1.0
 * @date 2021/8/28 23:36
 */
@RestController
@RequestMapping("/storage")
public class StorageContoller {

    @Autowired
    private StorageService storageService;

    @GetMapping("/hello")
    public String hello(){
        return "hello";
    }

    @GetMapping("/reduceStorage")
    public boolean reduceStorage(){
        Storage storage = new Storage();
        storage.setProductId(1);
        storage.setProductNumber(new BigDecimal(1));
        return  storageService.reduceStorage(storage);
    }


    @GetMapping("/reduceStorageException")
    public boolean reduceStorageException(){
        Storage storage = new Storage();
        storage.setProductId(1);
        storage.setProductNumber(new BigDecimal(1));
        return  storageService.reduceStorageException(storage);
    }

}
